<?php
	$validation_rules = array(
		"onair_episode_no" => array(
			"required" => true,
            'positiveInt' => true,
            'maxlength' => 9
		),
        'programme_title_cn' => array(
            'maxlength' => 255
        ),
        'programme_title_en' => array(
            'maxlength' => 255
        ),
        'programme_path' => array(
            'required' => true,
            #'path' => true,
            'maxlength' => 255
        )
	);
	
	if ($act==='view') {
        FormHelper::setReadonly(true);
        $validation_rules = array();
    }
    
	$programme_title_cn = isset($data['programme_title_cn']) ? $data['programme_title_cn'] : '';
	$programme_title_en = isset($data['programme_title_en']) ? $data['programme_title_en'] : '';
	$programme_path     = isset($data['programme_path']) ? $data['programme_path'] : '';
	$onair_episode_no  = isset($data['onair_episode_no']) ? $data['onair_episode_no'] : '';
	$programme_id       = isset($data['programme_id']) ? $data['programme_id'] : '';
?>

<div id="episode-step1" class="mod ui-widget-content ui-helper-clearfix ui-corner-all">
    <div class="hd ui-widget-header ui-helper-clearfix ui-corner-all"><h2><?php echo $act_text; ?> Episode</h2></div>
    <div class="bd">
	<?php FormHelper::StartForm('ane', AC::PDES_BASE_URL.'episode_step1.html?act=add&step=2') ?>
        <?php FormHelper::ErrorMessages($errors) ?>
        <fieldset class="ui-widget-content">
            <legend class="ui-widget-header">Find Programme Record</legend>
			<input id="programme_id" name="programme_id" type="hidden" value="<?php echo $programme_id;?>" />
            <div class="form-item">
                <span class="grid-l"><label><ins>**</ins>Programme Title (Chinese)</label> :</span>
                <span class="grid-r">
				<input id="programme_title_cn" name="programme_title_cn" type="text" class="text" autocomplete="off" value="<?php echo htmlentities($programme_title_cn, ENT_QUOTES, 'UTF-8');?>" />
                </span>
            </div>
            <div class="form-item">
                <span class="grid-l"><label><ins>**</ins>Programme Title (English)</label> :</span>
                <span class="grid-r">
				<input id="programme_title_en" name="programme_title_en" type="text" class="text" autocomplete="off" value="<?php echo htmlentities($programme_title_en, ENT_QUOTES, 'UTF-8');?>" /> 
                </span>
            </div>

            <div class="form-item">
                <span class="grid-l"><label><ins>*</ins>Programme Path</label> :</span>
                <span class="grid-r">
				<input id="programme_path" name="programme_path" type="text" class="text" autocomplete="off" value="<?php echo htmlentities($programme_path, ENT_QUOTES, 'UTF-8');?>" /> 
                </span>
            </div>

            <?php FormHelper::TextField('onair_episode_no', $onair_episode_no, "On Air Episode No.", '', 'number', 1)?>
	</fieldset>
        <span class="buttons">
		    <?php FormHelper::SubmitButton('submit', 'Create') ?>
        </span>
    	<?php FormHelper::EndForm() ?>
    </div>
</div>

<script>
    TVB.Pdes.oValidation = {
        form: document.forms['ane'],
        rules: <?php echo json_encode($validation_rules); ?>
    };
</script>
